﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using DAL;
namespace BLL
{
    public class SalaryTableBiz
    {
        SalaryTableDao salaryTableDao = new SalaryTableDao();
        BuiltSQL builtSQL = new BuiltSQL();
        public bool Update(string tableName, SortedDictionary<string, string> sdList)
        {
            return builtSQL.UpdateTable(tableName, sdList);
        }
        public bool Insert(string tableName, SortedDictionary<string, string> sdList)
        {
            return builtSQL.InsertTable(tableName, sdList);
        }
        public string Delete(string tableName, string[] sdList)
        {
            return builtSQL.DeleteTable(tableName, sdList);
        }
        public string GetSalID(string empCode, string strYear, string strMonth)
        {
            return salaryTableDao.GetSalID(empCode, strYear, strMonth);
        }
        public DataTable GetOneInfo(string empCode, string strYear, string strMonth)
        {
            return salaryTableDao.GetOneInfo(empCode, strYear, strMonth);
        }
        public bool DeleteOneInfo(string empCode, string strYear, string strMonth)
        {
            return salaryTableDao.DeleteOneInfo(empCode, strYear, strMonth);
        }

        public bool IsExistOneInfo(string empCode, string strYear, string strMonth)
        {
            return salaryTableDao.IsExistOneInfo(empCode, strYear, strMonth);
        }

        public bool IsExistSLTable(string strYear, string strMonth, string setsID)
        {
            return salaryTableDao.IsExistSLTable(strYear, strMonth, setsID);
        }

        public bool DeleteSLTable(string strYear, string strMonth, string setsID)
        {
            salaryTableDao.ExecuteSLSQL("Delete from Wage_Salary Where SalYear=" + strYear + " and SalMonth=" + strMonth + " and SetsID=" + setsID);
            return salaryTableDao.DeleteSLTable(strYear, strMonth, setsID);
        }
        public bool CreateLists(string strYear, string strMonth, string setsID)
        {
            //插入当月
            salaryTableDao.ExecuteSLSQL("Delete from Wage_Salary Where SalYear=" + strYear + " and SalMonth=" + strMonth + " and SetsID=" + setsID + ";insert into Wage_Salary values(" + strYear + "," + strMonth + "," + setsID + ",'N')");
            SqlParameter para0 = new SqlParameter("@theYear", SqlDbType.SmallInt);
            SqlParameter para1 = new SqlParameter("@theMonth", SqlDbType.TinyInt);
            SqlParameter para2 = new SqlParameter("@setsID", SqlDbType.Int);
            para0.Value = Int32.Parse(strYear);
            para1.Value = Int32.Parse(strMonth);
            para2.Value = Int32.Parse(setsID);

            SqlParameter[] spList = { para0, para1, para2 };
            // DataSet ds = new DepartmentBiz().GetDataSet("sp_JimProc_GetComID2", spList);
            return salaryTableDao.CreateLists(spList);
        }
        public string GetNextOrPre(string strYear, string strMonth, string empCode, string isNext)
        {
            return salaryTableDao.GetNextOrPre(strYear, strMonth, empCode, isNext);
        }
        public DataTable GetLists(string strYear, string strMonth, string setsID)
        {
            return salaryTableDao.GetLists(strYear, strMonth, setsID);
        }
        //查询
        public DataTable GetLists(string empCode, string strYear, string strMonth, string setsID)
        {
            return salaryTableDao.GetLists(empCode, strYear, strMonth, setsID);
        }
        //导出
        public DataTable GetLists(string empCode, string strYear, string strMonth, string setsID, string salIndex)
        {
            return salaryTableDao.GetLists(empCode, strYear, strMonth, setsID, salIndex);
        }
        public DataTable GetLists(string empCode, string deptName, string strYear, string strMonth, string setsID, string typeID)
        {
            return salaryTableDao.GetLists(empCode, deptName, strYear, strMonth, setsID, typeID);
        }
        public void ReCau(string setsID, string empCode, string strYear, string strMonth)
        {
            salaryTableDao.ReCau(setsID, empCode, strYear, strMonth);
        }
        //给以队列人设置帐套
        public bool ConfigAddBooks(ArrayList empCodeArray, string typeID)
        {
            return salaryTableDao.ConfigAddBooks(empCodeArray, typeID);
        }
        public bool ConfigDelBooks(ArrayList empCodeArray)
        {
            return salaryTableDao.ConfigDelBooks(empCodeArray);
        }

        public DataTable GetBooks(string typeID)
        { return salaryTableDao.GetBooks(typeID); }


        public bool IsMonthEnd(string strYear, string strMonth, string setsID)
        {
            return salaryTableDao.IsMonthEnd(strYear, strMonth, setsID);
        }
        public string ConfigMonthEnd(string strYear, string strMonth, string setsID)
        {
            return salaryTableDao.ConfigMonthEnd(strYear, strMonth, setsID);
        }
        public string ConfigReMonthEnd(string strYear, string strMonth, string setsID)
        {
            return salaryTableDao.ConfigReMonthEnd(strYear, strMonth, setsID);
        }
        
        //整体修改
        public bool AddSalary(string setsID, string strYear, string strMonth, string wageItem, string empRange, string isAdd, string modiWay, string num)
        {
           
            return salaryTableDao.AddSalary(setsID, strYear, strMonth, wageItem, empRange, isAdd, modiWay, num);
        }

        //设置银行代发文件格式
        public bool UpdateFileFormat(string fileFormat)
        {
            return salaryTableDao.UpdateFileFormat(fileFormat);
        }
        public string GetFileFormat()
        {
            return salaryTableDao.GetFileFormat();
        }
        public string GetFileType()
        { return salaryTableDao.GetFileType(); }
        public DataTable GetBankList(string strYear, string strMonth, string setsID, string fileFormat, string fileType)
        {
            return salaryTableDao.GetBankList(strYear, strMonth, setsID, fileFormat, fileType);
        }

        public DataTable GetLists()
        {
            return salaryTableDao.GetLists();
        }

        
        public DataTable SalaryTrend(string strYear,  string setsID)
        {
            return salaryTableDao.SalaryTrend(strYear,  setsID);
        }
        public DataTable SalaryTrendMonth(string strYear, string strMonth, string setsID)
        {
            return salaryTableDao.SalaryTrendMonth(strYear, strMonth, setsID);
        }
      
    }
}
